﻿@using TonyBlogs.DTO.UserPurview
@model UserPurviewEditDTO
@{
    Layout = null;
}



<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
    <h4 class="modal-title">@(Model.PurviewID == 0 ? "新增角色" : "修改角色")</h4>
</div>
<div class="modal-body">
    <div class="row">
        <div class="col-md-12">
            <form class="form-horizontal" role="form">
                <div class="form-body">
                    @Html.HiddenFor(m => m.PurviewID)
                    @Html.HiddenFor(m => m.PurviewFuncIDs)
                    <div class="form-group">
                        <label class="col-md-3 control-label">权限组名称</label>
                        <div class="col-md-9">
                            @Html.TextBoxFor(m => m.PurviewTitle, new { @class = " m-wrap" })
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-3 control-label">权限组描述</label>
                        <div class="col-md-9">
                            @Html.TextBoxFor(m => m.PurviewContent, new { @class = " m-wrap" })
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-3 control-label">权限节点</label>

                        <div class="col-md-9" style="margin-top:8px">
                            @*一级菜单*@

                            @foreach (var firItem in Model.FuncList)
                            {

                                <label class="checkbox">
                                    <input type="checkbox" name="FuncIDs" id="PurviewFuncIDs@(firItem.ID)" value="@firItem.ID" />&nbsp;@firItem.FucTitle
                                </label>

                                @*二级菜单*@
                                if (firItem.ChildList.Count > 0)
                                {
                                    <div style="margin-left: 25px;">
                                        @foreach (var secItem in firItem.ChildList)
                                        {
                                            <label class="checkbox" style="display:inline">
                                                <input type="checkbox" name="FuncIDs" id="PurviewFuncIDs@(secItem.ID)" value="@secItem.ID" />&nbsp;@secItem.FucTitle
                                            </label>
                                            <span>&nbsp; &nbsp;&nbsp; &nbsp;</span>
                                            @*三级菜单*@
                                            if (secItem.ChildList.Count() > 0)
                                            {
                                                <div style='margin-left: 25px;'>
                                                    @foreach (var trdItem in secItem.ChildList)
                                                    {
                                                        <label class="checkbox" style="display:inline">
                                                            <input type="checkbox" name="FuncIDs" id="PurviewFuncIDs@(trdItem.ID)" value="@trdItem.ID" />&nbsp;@trdItem.FucTitle
                                                        </label>
                                                        <span>&nbsp; &nbsp;&nbsp; &nbsp;</span>
                                                    }
                                                </div>
                                            }
                                        }
                                    </div>
                                }
                            }
                            
                        </div>
                    </div>
                </div>

            </form>
        </div>

    </div>
</div>
<div class="modal-footer">
    <button id="btnConfirm" class="btn green" type="button" aria-hidden="true">提交</button>
    <button class="btn btnclose" data-dismiss="modal" aria-hidden="true">关闭</button>
</div>

<script type="text/javascript">

    $(document).ready(function () {
        var PurviewFuncIDs = "@Model.PurviewFuncIDs";
        if (PurviewFuncIDs != "") {
            var funList = new Array();
            funList = PurviewFuncIDs.split(",");
            for (var i = 0; i < funList.length; i++) {
                if (document.getElementById("PurviewFuncIDs" + funList[i]) != null)
                    $("#PurviewFuncIDs" + funList[i]).attr("checked", "checked");
            }
        }
    });
</script>
